package com.softaria.windows.widgets;

import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.softaria.windows.styles.HelperPanelStyles;

/**
 * Panel with context help information.
 * 
 */
public class HelpPanel extends VerticalPanel implements HelperPanelStyles {

  private HTML helperText;
  private Label helperTitle;
  private ScrollPanel scrollPanel;

  public HelpPanel() {

    setStylePrimaryName(HELPER_PANEL_STYLE);

    VerticalPanel panel = new VerticalPanel();

    helperTitle = new Label();

    helperTitle.setStylePrimaryName(HELP_TITLE_STYLE);

    helperText = new HTML();

    helperText.setStylePrimaryName(HELP_TEXT_STYLE);

    panel.add(helperTitle);
    panel.add(helperText);

    scrollPanel = new ScrollPanel(panel);

    add(scrollPanel);

    // TODO - looks like a hack
    helperText.setHTML("&nbsp;");
  }

  /**
   * Sets text on help panel
   */
  public void setText(String text) {
    helperText.setText(text);
  }

  public void setTitle(String title) {
    helperTitle.setText(title);
  }

  void setScrollHeight(int pixels) {
    scrollPanel.setHeight(pixels + "px");
  }
}
